<?php session_start();
include "constants.php";
$dates=date_create(CUTOFFS);
$cutoffdates=date_format($dates,"m/d/Y");
$displays=SHOWOFFS;
$INITIALS=SPOINT;

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 

if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(DB_NAME);

$newip = $_SERVER['REMOTE_ADDR'];
$Employee=$_SESSION['Username'];
$coup=$_SESSION['Coupon'];


if(!isset($Employee)||empty($Employee)||$newip!= $_SESSION['IP'])
{echo "If you are payday loan applicant, please start your ". "<a href='apply.php'>application here</a> now, thank you for your cooperation!";
exit();
}

//The following part is to set up interactive function between user and server
$status = $accountid = $accountinf = $decision= $reason=$approvedloan=null; //declare vars
$payment=$CID=$queryquestions=null;
$startingday=$endingday=0;

//$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
//	if (!$link) { 
//	    die('Could not connect: ' . mysql_error()); 
//		} 
//mysql_select_db(cash2uca);

if(isset($_POST["status"]) && is_numeric($_POST["status"]))
{
    $status = $_POST["status"];
}

if(isset($_POST["CID"]) && is_numeric($_POST["CID"]))
{
    $CID = $_POST["CID"];
}

if(isset($_POST["accountid"]) && is_numeric($_POST["accountid"]))
{
    $accountid = $_POST["accountid"];
	$sqlPR = "SELECT * FROM Applications WHERE AccountID = $accountid";
        $PR = mysql_query($sqlPR,$link);
	$rowPR = mysql_fetch_array($PR);
	$NVsts=$rowPR['NumberofVisits'];
	$coup100=$rowPR['COUPON'];
	$cost100=$rowPR['COST_100'];
	$PRID=$rowPR['ProfileID'];
	if($NVsts>1){
		$sql = "SELECT * FROM Applications WHERE ProfileID=$PRID and NumberofVisits=($NVsts-1)";
        	$result = mysql_query($sql,$link);
		$rows = mysql_fetch_array($result);
		$Credits=$rows['Credits'];

		$PREAccountID=$rows['AccountID'];
		$APPROVEDSTATUS=$rows['NewApp'];

		$sql = "SELECT COUNT(*) as NSFTIMES FROM Applications WHERE ProfileID=$PRID and AccountID=$PREAccountID";
        	$result = mysql_query($sql,$link);
		$rows = mysql_fetch_array($result);
		$NSFS=$rows['NSFTIMES'];

	} else {$Credits=0;}

//To get profile for the applicant
	$Profiles = "SELECT * FROM Profiles WHERE ProfileID = $PRID";
        $ProfResu = mysql_query($Profiles,$link);
	$rowProf = mysql_fetch_array($ProfResu);
	$_SESSION['FirstName']=$rowProf['FirstName'];
	$_SESSION['LastName']=$rowProf['LastName'];
	$_SESSION['Gender']=$rowProf['Gender'];
	$_SESSION['BirthDate']=$rowProf['BirthDate'];
	$_SESSION['Address']=$rowProf['Address'];
	$_SESSION['City']=$rowProf['City'];
	$_SESSION['Province']=$rowProf['Province'];
	$_SESSION['PostCode']=$rowProf['PostCode'];
	$_SESSION['DateIn']=$rowProf['DateIn'];
	$_SESSION['PrimaryPhone']=$rowProf['PrimaryPhone'];
	$_SESSION['WorkPhone']=$rowProf['WorkPhone'];
	$_SESSION['CellPhone']=$rowProf['CellPhone'];
	$_SESSION['Email']=$rowProf['Email'];
	$_SESSION['Advertisement']=$rowProf['Advertisement'];
	$_SESSION['SIN']=$rowProf['SIN'];
	$_SESSION['DriverLicense']=$rowProf['DriverLicense'];
	$_SESSION['R1Name']=$rowProf['R1Name'];
	$_SESSION['R2Name']=$rowProf['R2Name'];
	$_SESSION['R1Phone']=$rowProf['R1Phone'];
	$_SESSION['R2Phone']=$rowProf['R2Phone'];
	$_SESSION['R1Relation']=$rowProf['R1Relation'];
	$COMMENTS=$rowProf['COMMENTS'];
}

if(isset($_POST["accountinf"]) && is_numeric($_POST["accountinf"]))
{
    $accountinf = $_POST["accountinf"];
}

if(isset($_POST["decision"]) && is_numeric($_POST["decision"]))
{
    $decision = $_POST["decision"];

}

if(isset($_POST["reasons"]) && is_numeric($_POST["reasons"]))
{
    $reason = $_POST["reasons"];

}

if(isset($_POST["payments"]) && is_numeric($_POST["payments"]))
{
    $payment = $_POST["payments"];

}


if(isset($_POST["approvedloan"]) && is_numeric($_POST["approvedloan"]))
{
$approvedloan = $_POST["approvedloan"];
$tcost="$".$coup100*0.01*$cost100*$approvedloan;	}


if(isset($_POST["queryquestions"]) && is_numeric($_POST["queryquestions"]))
{
    $queryquestions = $_POST["queryquestions"];

}
if(isset($_POST["startingday"]))
{
    $startingday = $_POST["startingday"];

}
if(isset($_POST["endingday"]))
{
    $endingday = $_POST["endingday"];

}


//The above part end

if(!isset($_SESSION['Username'])||empty($_SESSION['Username'])||$newip!= $_SESSION['IP'])
{echo "If you are payday loan applicant, please start your ". "<a href='apply.php'>application here</a> now, thank you for your cooperation!";
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cash2u.ca: Payday loan online processing</title>
<META NAME="Keywords" CONTENT="How it works, payday loans,cash advance, payday loan, pay day loans, payday cash advance, online, unsecured loans, no fax payday loans, payday advance, payday cash loan, payday loans, cash advance, paycheque loans, short term,fast cash, unsecured personal loans, pay day loan, no fax loans, no faxing payday loans, no fax cash advance, faxless payday loans, short term loans, unsecured personal loan, unsecured loan, online loans, quick cash, no fax payday loan, payday cash advance, cash advance, online loan, fast cash loans, signature loan, no fax pay day loans, pay day advance, payday loans no faxing required, payday loan online, no faxing cash advance, payday loans no faxing, canada, money mart, money here, quick cash,check,cashing,easy,tax, bill,payment,currency,card,credit,Easy Cash Advances,Internet Payday loans, Payroll Advance, Payday Loan Services,Online Payday Advances, Online Payday Loan Provider, Pay Day">
<META NAME="Description" CONTENT=Cash2u.ca offers online payday loans and cash advance for Canadians">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="./css/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="./css/main_style.css"/>
<link rel="stylesheet" type="text/css" href="./css/index.css"/>
<script type="text/javascript" src="validationjava.js"></script>
<script src="formavalidates.js" type="text/javascript"></script>
<script src="/css/newdecisionprocess.js" type="text/javascript"></script>
<style type="text/css">@import "/css/jquery.datepick.css";</style>
<script type="text/javascript" src="/css/jquery.datepick.js"></script>
<script type="text/javascript">
$(function() {
	$('#scheduledpayday').datepick({yearRange: '1900:+1'});
	$('#setuppadday').datepick({yearRange: '1900:+1'});
	$('#newpadday').datepick({yearRange: '1900:+1'});

});
function showDate(date) {
	alert('The date chosen is ' + date);
}
</script>

<script type="text/javascript">
function autoSubmit()
{
    var formObject = document.forms['newprocess'];
    formObject.submit();
}

</script>


</head>
<body>
<div id="maincontainer">

<div id="headsection">
<div id="headback">
<br/><br/><br/><h1><a style="color:white;" href="apply.php">Cash to you</a></h1><p id="headpara"><a style="color:white;" href="apply.php">Simple Easy Fast - Your payday loan</a></p>
</div>
</div>

<table cellspacing="4" cellpadding="1" border="0" style="margin:5px;height:50px;width:740px;background-color:#084c8d;border:1px solid #e5e5e5;color:white;font-size:110%;font-weight:bold;">
<tr><td width="20"></td>
<td width="110" align="center"><a class="headlink" href="NewAppliation.php">Application</a></td>
<td width="110" align="center"><a class="headlink" href="management.php" target="_blank">Management</a></td>
<td width="110" align="center"><a class="headlink" href="reports.php" target="_blank">Reports</a></td>
<td width="110" align="center"></td>
<td width="110" align="center"></td>
<td width="110" align="center"></td>
<td width="110" align="center"><a class="headlink" href="logout.php">Log out</a></td>
<td width="110"></td>
</tr>
</table>

<div id="content">
    	<div id="Apphead" class="Apphead" style="margin: 20px 0 0 5px;">
        	<h3>APPLICATION PROCESS</h3>            
    	</div>
        <!-- EOD of Application Head -->    
          
        <div id="TopSectionWrapper" class="PersonalInfo">

<!---------------------------------------------------------------------------------------------->


<form name="newprocess" method="post">
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
<tr><td width="700" align="center">Please Select the Application Status to Process</td></tr>
<tr><td width="700" align="center">    
    <select style="width: 220px;" name="status" onChange="autoSubmit();">
	<option value="null">Please select application status</option>
	<option value="1" <?php if($status == 1) echo " selected"; ?>>New Application</option>
	<option value="7" <?php if($status == 7) echo " selected"; ?>>Approved Loan</option>
	<!--option value="2" <?php if($status == 2) echo " selected"; ?>>Loan Paid</option-->
        <option value="3" <?php if($status == 3) echo " selected"; ?>>Scheduled Repaying</option>
       	<option value="4" <?php if($status == 4) echo " selected"; ?>>NSF</option>
       	<!--option value="5" <?php if($status == 5) echo " selected"; ?>>Failed Application</option-->
       	<!--option value="6" <?php if($status == 6) echo " selected"; ?>>Contact Information</option-->
       	<option value="9" <?php if($status == 9) echo " selected"; ?>>Collection Agency</option>
    </select></td></tr><tr></tr>
<table>

<?php if($status == 3||$status == 4||$status == 9)  {    ?>
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
<tr><td width="700" align="center">Please Select starting date</td></tr>
<tr><td width="700" align="center"><!--input type="text" style="width: 150px;" name="startingday" id="startingday"-->

	<select style="width: 220px;" name="startingday" onChange="autoSubmit();">        
        <option value="0">--select starting day--</option>        
        <?php        
        $sql = "SELECT DISTINCT CollectDate FROM Applications WHERE NewApp='$status' AND Datediff(SignDate , STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0 ORDER BY Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ), '%Y' ) DESC,Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ),'%m' ) DESC, Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ),'%d' ) DESC";
        $accounts = mysql_query($sql,$link);        
        while($row = mysql_fetch_array($accounts)) {        
            echo ("<option value=\"$row[CollectDate]\" " . ($startingday == $row["CollectDate"] ? " selected" : "") . ">$row[CollectDate]</option>");  }  ?>        
	</select></td></tr>


<tr><td width="700" align="center">Please Select ending date</td></tr>
<tr><td width="700" align="center"><!--input type="text" style="width: 150px;" name="endingday" id="endingday"-->
	<select style="width: 220px;" name="endingday" onChange="autoSubmit();">        
        <option value="0">--select ending day--</option>        
        <?php        
        $sql = "SELECT DISTINCT CollectDate FROM Applications WHERE Datediff(SignDate, STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0 AND NewApp='$status' ORDER BY Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ), '%Y' ) DESC,Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ),'%m' ) DESC, Date_Format(STR_TO_DATE(CollectDate , '%m/%d/%Y' ),'%d' ) DESC";
        $accounts = mysql_query($sql,$link);        
        while($row = mysql_fetch_array($accounts)) {        
            echo ("<option value=\"$row[CollectDate]\" " . ($endingday == $row["CollectDate"] ? " selected" : "") . ">$row[CollectDate]</option>");  }  ?>        
	</select>
</td></tr>


</table>
<?php }    ?>

<table>
<!--The following part is used to select application ID except Status=6: Testing Status no Status=3-->
    <?php if($status != null && is_numeric($status) && $status!=6 && $status!=3 && $status!=4 && $status!=9)  { ?>
    <tr><td width="700" align="center">Please Select the Application AccountID to Process</td></tr>
    <tr><td width="700" align="center">  
    <select style="width: 220px;" name="accountid" onChange="autoSubmit();">        
        <option value="null">Please select Application AccountID</option>
        
        <?php        
        //POPULATE DROP DOWN MENU WITH COUNTRIES FROM A GIVEN status
        $sql = "SELECT *,AccountID-$INITIALS AS ONES FROM Applications WHERE NewApp=$status AND Datediff(SignDate , STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0 ORDER BY AccountID";
        $accounts = mysql_query($sql,$link);        
        while($row = mysql_fetch_array($accounts)) {        
            echo ("<option value=\"$row[AccountID]\" " . ($accountid == $row["AccountID"] ? " selected" : "") . ">$row[ONES]</option>");  }  ?>
        
    </select></td></tr><tr></tr><tr></tr>
  
    <?php    }    ?> 

 <?php if(($status==3||$status==4||$status==9) && $startingday!=0 && $endingday!=0)  { ?>
    <tr><td width="700" align="center">Please Select the Application AccountID to Process</td></tr>
    <tr><td width="700" align="center">  
    <select style="width: 220px;" name="accountid" onChange="autoSubmit();">        
        <option value="null">Please select Application AccountID</option>
        
        <?php        
        //POPULATE DROP DOWN MENU WITH COUNTRIES FROM A GIVEN status
        $sql = "SELECT *,AccountID-$INITIALS AS ONES FROM Applications WHERE Datediff(SignDate , STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0 AND NewApp='$status' AND 
			Datediff(STR_TO_DATE(CollectDate , '%m/%d/%Y') , STR_TO_DATE('$startingday' , '%m/%d/%Y' ))>=0 AND
			Datediff(STR_TO_DATE(CollectDate , '%m/%d/%Y' ) , STR_TO_DATE('$endingday' , '%m/%d/%Y' ) )<=0 ORDER BY AccountID";
        $accounts = mysql_query($sql,$link);        
        while($row = mysql_fetch_array($accounts)) {        
            echo ("<option value=\"$row[AccountID]\" " . ($accountid == $row["AccountID"] ? " selected" : "") . ">$row[ONES]</option>");  }  ?>
        
    </select></td></tr><tr></tr><tr></tr>
  
    <?php    }    ?>
<!--The above part is used to select application ID-->

<!--The following part is used to process contact information-->
    <?php if($status != null && is_numeric($status) && $status==6)  { ?>
    <tr><td width="700" align="center">Please Select One Contact Information to Process</td></tr>
    <tr><td width="700" align="center">  
    <select style="width: 220px;" name="CID" onChange="autoSubmit();">        
        <option value="null">Please select ContactID</option>
        
        <?php        
        //POPULATE DROP DOWN MENU WITH COUNTRIES FROM A GIVEN status
        $sql = "SELECT * FROM Comments WHERE CONTACT='1'";
        $accounts = mysql_query($sql,$link);        
        while($row = mysql_fetch_array($accounts)) {        
            echo ("<option value=\"$row[CID]\" " . ($CID == $row["CID"] ? " selected" : "") . ">$row[CID]</option>");  }  ?>
        
    </select></td></tr><tr></tr><tr></tr>
  
    <?php    }    ?>
<!--The above part is used to process contact information-->

</table>   

<!--To process deposit and debit money for the approved loan applications-->
<?php if($accountid != null && is_numeric($accountid) && $status == 7)  {    ?>
<!--table name="accountinf" onChange="autoSubmit();" cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;"-->	
<table name="accountinf" cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">	
<?php        
        //POPULATE DROP DOWN MENU WITH STATES FROM A GIVEN status, COUNTRY
        
        $sql = "SELECT * FROM Applications WHERE AccountID = $accountid AND Datediff(SignDate , STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0";
        $states = mysql_query($sql,$link);
        
        while($row = mysql_fetch_array($states))
        {
	$PROFEID=$row['ProfileID'];
        $ACCID=$row['AccountID'];
	$LAmt=$row['BAmount'];
	$Lcst=$row['Costs'];
	$FPday=$row['FirstPayDay'];
	$AppLAmt=$row['ApprovalAmount'];
	$AppLcst=$row['TotalCost'];
	$SchPday=$row['CollectDate'];
	$SPday=$row['SecondPayDay'];
	$Banking=$row['BankName'];		     
	$TranID=$row['TransitID'];
	$DebitID=$row['DebitID'];
	$DebitPWD=$row['DebitPWD'];
	$SQ1=$row['SQ1'];
	$SQ2=$row['SQ2'];
	$SQ3=$row['SQ3'];
	$SQ4=$row['SQ4'];
	$SQ5=$row['SQ5'];
	$AS1=$row['AS1'];
	$AS2=$row['AS2'];
	$AS3=$row['AS3'];
	$AS4=$row['AS4'];
	$AS5=$row['AS5'];
	$Employer=$row['Employer'];
	$EPhone=$row['EPhone'];
	$DateHired=$row['DateHired'];
	$JobStatus=$row['JobStatus'];
	$PayType=$row['PayType'];
	$PayFrequency=$row['PayFrequency'];
	$MonthlyIncome=$row['MonthlyIncome'];
	$PayBy=$row['PayBy'];
	$InstitutionID=$row['InstitutionID'];
	$CheckID=$row['CheckID'];
	$DIFF=$row['DD'];
	
        }     ?>    
	<tr>
	<td width="140" ></td>
        <td width="400"align="center"><strong>Applicant's Approved Loan Information</strong></td>        
        <td width="160"></td>
	</tr>
</table>
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<?php if($displays==1) { ?>
	<tr>
	<td width="140" align="right">AccountID:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $ACCID;?>"></td>
        <td width="230" align="right">Visit Times:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $NVsts;?>"></td>
	</tr>
	<?php } ?>
	<tr>
	<td width="140" align="right">Approved Amount:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $AppLAmt;?>"></td>
        <td width="230" align="right">Total Loan Cost:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $AppLcst;?>"></td>
	</tr>

	<tr>
	<td width="140" align="right">Scheduled PAD Day:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $SchPday;?>"></td>
        <td width="230" align="right">First Pay Day:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $FPday;?>"></td>
	</tr>
</table>

<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<p>Please make sure PAD payment and PAD deposit are set up appropriately</p>
</table>
	
<?php } ?>
<!--Deposit and Debit Loan process ends-->

   <!--The following part is used to process scheduled repaying application-->
 <?php if($accountid != null && is_numeric($accountid) && ($status == 3||$status==4||$status==9))  {    ?>
 <table name="accountinf" cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">	
	<?php
        
        //POPULATE DROP DOWN MENU WITH STATES FROM A GIVEN status, COUNTRY
        
        $sql = "SELECT * FROM Applications WHERE AccountID = $accountid AND Datediff(SignDate, STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0";
        $states = mysql_query($sql,$link);
        
        while($row = mysql_fetch_array($states))
        {
	$PROFEID=$row['ProfileID'];
        $ACCID=$row['AccountID'];
	$LAmt=$row['BAmount'];
	$Lcst=$row['Costs'];
	$FPday=$row['FirstPayDay'];
	$AppLAmt=$row['ApprovalAmount'];
	$AppLcst=$row['TotalCost'];
	$ExpectedPay=$AppLAmt*(1+$coup100*0.01*$cost100);
	$PAIDAMOUNT=$row['PaidAmount'];
	$NSFExpectedPay=$row['NewAmount'];
	$SchPday=$row['CollectDate'];
	$SPday=$row['SecondPayDay'];
	$Banking=$row['BankName'];		     
	$TranID=$row['TransitID'];
	$DebitID=$row['DebitID'];
	$DebitPWD=$row['DebitPWD'];
	$SQ1=$row['SQ1'];
	$SQ2=$row['SQ2'];
	$SQ3=$row['SQ3'];
	$SQ4=$row['SQ4'];
	$SQ5=$row['SQ5'];
	$AS1=$row['AS1'];
	$AS2=$row['AS2'];
	$AS3=$row['AS3'];
	$AS4=$row['AS4'];
	$AS5=$row['AS5'];
	$Employer=$row['Employer'];
	$EPhone=$row['EPhone'];
	$DateHired=$row['DateHired'];
	$JobStatus=$row['JobStatus'];
	$PayType=$row['PayType'];
	$PayFrequency=$row['PayFrequency'];
	$MonthlyIncome=$row['MonthlyIncome'];
	$PayBy=$row['PayBy'];
	$InstitutionID=$row['InstitutionID'];
	$CheckID=$row['CheckID'];
	$DIFF=$row['DD'];
	
        }        
        ?>    
	<tr>
	<td width="140" ></td>
        <td width="400"align="center"><strong>Applicant's Approved Loan Information</strong></td>        
        <td width="160"></td>
	</tr>
	</table>
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<?php if($displays==1) { ?>
	<tr>
	<td width="140" align="right">AccountID:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $ACCID;?>"></td>
        <td width="230" align="right">Visit Times:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $NVsts;?>"></td>
	</tr>
	<?php } ?>
	<tr>
	<td width="140" align="right">Scheduled PAD Day:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $SchPday;?>"></td>
        <td width="230" align="right">First Pay Day:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $FPday;?>"></td>
	</tr>

	<tr>
	<td width="140" align="right">Approved Amount:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $AppLAmt;?>"></td>
        <td width="230" align="right">Cost:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $AppLcst;?>"></td>
	</tr>	

	
</table>

	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
	<td width="140" align="right">Status of Payment:</td>
        <td width="170"><select style="width: 150px;" name="payments" onChange="autoSubmit();">
			<option value="null">- Select -</option>	
			<option value="2" <?php if($payment == 2) echo " selected"; ?>>PAID->Email out</option>  
			<option value="22" <?php if($payment == 22) echo " selected"; ?>>PAID->No email out</option>  
			<?php if($status==3||$status==4) { ?>
			<option value="4" <?php if($payment == 4) echo " selected"; ?>>NSF_$36</option>	
			<option value="44" <?php if($payment == 44) echo " selected"; ?>>NSF_As New Loan</option>	
			<option value="9" <?php if($payment == 9) echo " selected"; ?>>Collection Agency</option>	
			<?php } ?>
			<option value="8" <?php if($payment == 8) echo " selected"; ?>>Default</option>	
		</select> </td></tr>		
	</table>	
<?php } ?>
    
   <!--The above part is used to process scheduled repaying application-->

   <!--The following part is used to process new appliation-->
    <?php if($accountid != null && is_numeric($accountid) && $status == 1)  {    ?>
 <table name="accountinf" onChange="autoSubmit();" cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">	
	<?php
        
        //POPULATE DROP DOWN MENU WITH STATES FROM A GIVEN status, COUNTRY
        
        $sql = "SELECT * FROM Applications WHERE AccountID = $accountid AND Datediff(SignDate , STR_TO_DATE('$cutoffdates' , '%m/%d/%Y' ))>0";
        $states = mysql_query($sql,$link);
        
        while($row = mysql_fetch_array($states))
        {
	$PROFEID=$row['ProfileID'];
        $ACCID=$row['AccountID'];
	$LAmt=$row['BAmount'];
	$Lcst=$row['Costs'];
	$FPday=$row['FirstPayDay'];
	$SPday=$row['SecondPayDay'];
	$Banking=$row['BankName'];		     
	$TranID=$row['TransitID'];
	$DebitID=$row['DebitID'];
	$DebitPWD=$row['DebitPWD'];
	$SQ1=$row['SQ1'];
	$SQ2=$row['SQ2'];
	$SQ3=$row['SQ3'];
	$SQ4=$row['SQ4'];
	$SQ5=$row['SQ5'];
	$AS1=$row['AS1'];
	$AS2=$row['AS2'];
	$AS3=$row['AS3'];
	$AS4=$row['AS4'];
	$AS5=$row['AS5'];
	$Employer=$row['Employer'];
	$EPhone=$row['EPhone'];
	$DateHired=$row['DateHired'];
	$JobStatus=$row['JobStatus'];
	$PayType=$row['PayType'];
	$PayFrequency=$row['PayFrequency'];
	$MonthlyIncome=$row['MonthlyIncome'];
	$PayBy=$row['PayBy'];
	$InstitutionID=$row['InstitutionID'];
	$CheckID=$row['CheckID'];
        }        
        ?>    
	<tr>
	<td width="140" ></td>
        <td width="170"align="right"><strong>Applicant's Loan</strong></td>
        <td width="230" align="left"><strong>Application Information</strong></td>
        <td width="160"></td>
	</tr>
	<?php if($displays==1) { ?>
	<tr>
	<td width="140" align="right">AccountID:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $ACCID;?>"></td>
        <td width="230" align="right">Visit Times:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $NVsts;?>"></td>
	</tr>
	<?php } ?>
	<tr>
	<td width="140" align="right">Loan Amount:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $LAmt;?>"></td>
        <td width="230" align="right">Loan Cost:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $Lcst;?>"></td>
	</tr>

	<tr>
	<td width="140" align="right">First Pay Day:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $FPday;?>"></td>
        <td width="230" align="right">Second pay Day:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php echo $SPday;?>"></td>
	</tr>
</table>


	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr><td width="700" align="left" style="color:blue;">
Please verify the applicant's banking information from the checking account which the applicant provided in the below to decide whether we will approve the applicant's payday loan or refuse the loan. Please also check the applicant's profile to see whether or not we refused it's application before.
	</td></tr>
	<?php if($COMMENTS!=NULL && $COMMENTS!="NO COMMENT") { ?>
	<tr><td width="700" align="left" style="color:red;">Special comments:<?php echo $COMMENTS;?>
	</td></tr>
	<?php } ?>
	</table>
<!--This is to process the previous application to help approve process-->
<?php if($NVsts>1) { ?>
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
	<td width="140" align="right">Previous AccountID:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $PREAccountID;?>"></td>
        <td width="230" align="right">Status of Loan:</td>
        <td width="160"><input type="text" style="width: 150px;" value="<?php if($APPROVEDSTATUS==3){echo "Scheduled Repaying";} else if($APPROVEDSTATUS==4){echo "NSF";} ?>"></td>
	</tr>
</table>
<?php } ?>
<!--This is to process the previous application to help approve process-->
	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
	<td width="140" align="right">Approval or Refuse?</td>
	<td width="170">    
	    <select style="width: 150px;" name="decision" onChange="autoSubmit();">
		<option value="null">Please decide approval</option>
		<option value="3" <?php if($decision == 3) echo " selected"; ?>>Approval</option>
		<option value="5" <?php if($decision == 5) echo " selected"; ?>>Refuse</option>
		<option value="10" <?php if($decision == 10) echo " selected"; ?>>Questions</option>
	    </select></td>
	<?php if($decision != null && $decision==5)  { ?>
	<td width="230" align="right">Reason to Refuse:</td>
        <td width="160"><select style="width: 150px;" name="reasons" onChange="autoSubmit();">
			<option value="null">- Select -</option>	
			<option value="1" <?php if($reason == 1) echo " selected"; ?>>Seasonal Job</option>
			<option value="2" <?php if($reason == 2) echo " selected"; ?>>Low Income($1400m)</option> 
			<option value="3" <?php if($reason == 3) echo " selected"; ?>>unemployment</option>
			<option value="4" <?php if($reason == 4) echo " selected"; ?>>under 19 years old</option>	
			<option value="5" <?php if($reason == 5) echo " selected"; ?>>Mulitple Application in one Account</option>
			<option value="6" <?php if($reason == 6) echo " selected"; ?>>Default on loans</option>
			<option value="7" <?php if($reason == 7) echo " selected"; ?>>Bank history <3 months</option>
			<option value="8" <?php if($reason == 8) echo " selected"; ?>>Too many loans</option>
			<option value="9" <?php if($reason == 9) echo " selected"; ?>>Child Tax Benefit</option>
			<option value="10" <?php if($reason == 10) echo " selected"; ?>>Invalid Debit# or password</option>
			<option value="11" <?php if($reason == 11) echo " selected"; ?>>Unanswered Securiyt Questions</option>
			<option value="12" <?php if($reason == 12) echo " selected"; ?>>Online Fraud</option>
			<option value="13" <?php if($reason == 13) echo " selected"; ?>>others</option>
		</select> </td>
	<?php } ?>
	<?php if($decision != null && $decision==10)  { ?>
	<td width="230" align="right">Questions:</td>
        <td width="160"><select style="width: 150px;" name="queryquestions" onChange="autoSubmit();">
			<option value="null">- Select -</option>	
			<option value="1" <?php if($queryquestions == 1) echo " selected"; ?>>no seuciryt questions/answers</option>
			<option value="2" <?php if($queryquestions == 2) echo " selected"; ?>>invalid debit#/password</option> 
			<option value="3" <?php if($queryquestions == 3) echo " selected"; ?>>more security questions/answers</option>
			<option value="4" <?php if($queryquestions == 4) echo " selected"; ?>>remove application</option>	
			<option value="5" <?php if($queryquestions == 5) echo " selected"; ?>>waiting for clear payment</option>
			<option value="6" <?php if($queryquestions == 6) echo " selected"; ?>>Online disabled</option>
			<option value="7" <?php if($queryquestions == 7) echo " selected"; ?>>security questions and invalid Debit#/PWD</option>
			<option value="8" <?php if($queryquestions == 8) echo " selected"; ?>>unpaid outstanding loans</option>
		</select> </td>
	<?php } ?>
	</tr><br/></table>
<!--The following part is used to process approved new application-->
<?php if($decision != null && $decision==3)  { ?>

<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr><td width="700" align="left">
		<?php if($displays==1) { ?>Since this is applicant's <span style="color:green;"><?php echo $NVsts;if($NVsts==1){echo st;} else if($NVsts==2){echo nd;} else if($NVsts==3){echo rd;} else{th;} ?></span> time loan application, according to our policy, the maximum loan amount is  <span style="color:green;"><?php if($NVsts==1){echo "$100";} else if($NVsts==2){echo "$150";} else if($NVsts==3){echo "$200";} else if($NVsts==4){echo "$300";} else if($NVsts==5){echo "$400";} else if($NVsts==6){echo "$500";} else {echo "$600";} ?></span>.<?php } ?> We have approved the payday loan, please schedule to collect the loan on the first pay day and submit
	</td></tr>
	<?php if($Credits!=0)  { ?>	
	<tr><td width="700" align="left">Approved Credits: <?php echo $Credits;?>. If this approved credit is not 0, then please approve the loan application based on the credits</td></tr>
	<?php } ?>
	</table>
	
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
	<td width="140" align="right">Approved Loan:</td>
        <td width="170"><!--input type="text" style="width: 150px;" value="<?php echo $Lcst;?>"-->
	<select style="width: 150px;" name="approvedloan" onChange="autoSubmit();">
			<option value="0">- Select -</option>	
	<?php if($NVsts==1){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
	<?php  }   ?>

	<?php if($NVsts==2){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
	<?php  }   ?>
	<?php if($NVsts==3){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
			<option value="200" <?php if($approvedloan == 200) echo " selected"; ?>>200</option>
	<?php  }   ?>
	<?php if($NVsts==4){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
			<option value="200" <?php if($approvedloan == 200) echo " selected"; ?>>200</option>	
			<option value="250" <?php if($approvedloan == 250) echo " selected"; ?>>250</option>
			<option value="300" <?php if($approvedloan == 300) echo " selected"; ?>>300</option>
	<?php  }   ?>
	<?php if($NVsts==5){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
			<option value="200" <?php if($approvedloan == 200) echo " selected"; ?>>200</option>	
			<option value="250" <?php if($approvedloan == 250) echo " selected"; ?>>250</option>
			<option value="300" <?php if($approvedloan == 300) echo " selected"; ?>>300</option>
			<option value="350" <?php if($approvedloan == 350) echo " selected"; ?>>350</option>
			<option value="400" <?php if($approvedloan == 400) echo " selected"; ?>>400</option>
	<?php  }   ?>
	<?php if($NVsts==6){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
			<option value="200" <?php if($approvedloan == 200) echo " selected"; ?>>200</option>	
			<option value="250" <?php if($approvedloan == 250) echo " selected"; ?>>250</option>
			<option value="300" <?php if($approvedloan == 300) echo " selected"; ?>>300</option>
			<option value="350" <?php if($approvedloan == 350) echo " selected"; ?>>350</option>
			<option value="400" <?php if($approvedloan == 400) echo " selected"; ?>>400</option>
			<option value="450" <?php if($approvedloan == 450) echo " selected"; ?>>450</option>
			<option value="500" <?php if($approvedloan == 500) echo " selected"; ?>>500</option>
	<?php  }   ?>
	<?php if($NVsts>6){ ?>	
			<option value="50" <?php if($approvedloan == 50) echo " selected"; ?>>50</option>
			<option value="100" <?php if($approvedloan == 100) echo " selected"; ?>>100</option> 
			<option value="150" <?php if($approvedloan == 150) echo " selected"; ?>>150</option>
			<option value="200" <?php if($approvedloan == 200) echo " selected"; ?>>200</option>	
			<option value="250" <?php if($approvedloan == 250) echo " selected"; ?>>250</option>
			<option value="300" <?php if($approvedloan == 300) echo " selected"; ?>>300</option>
			<option value="350" <?php if($approvedloan == 350) echo " selected"; ?>>350</option>
			<option value="400" <?php if($approvedloan == 400) echo " selected"; ?>>400</option>
			<option value="450" <?php if($approvedloan == 450) echo " selected"; ?>>450</option>
			<option value="500" <?php if($approvedloan == 500) echo " selected"; ?>>500</option>
			<option value="550" <?php if($approvedloan == 550) echo " selected"; ?>>550</option>
			<option value="600" <?php if($approvedloan == 600) echo " selected"; ?>>600</option>
	<?php  }   ?>
		</select>                
	</td>
	<?php if($approvedloan != null && $approvedloan!=0)  { ?>
        <td width="230" align="right">Approved Loan Cost:</td>
        <td width="160"><input type="text" style="width: 150px;" name="napprovedcost" readonly value="<?php echo $tcost;?>"></td>
	</tr>
	<?php  }    ?>	
<?php  }    ?>


    </table>
    
    <?php     }    ?>

</form>


<!--The following form is to submit the loan application-->
<form name="approve_refuse" method="post" action="decisionprocess.php" target="_blank">
<table>	
<tr>
<td width="140" align="right"  style="visibility:hidden;">Application Status:</td>
<td width="170"  style="visibility:hidden;"><input type="text" style="width: 150px;" name="appstatus" id="appstatus" value="<?php echo $status;?>"></td>
<td width="230" align="right"  style="visibility:hidden;">Application Decision:</td>
<td width="160"  style="visibility:hidden;"><input type="text" style="width: 150px;" name="appdecision" id="appdecision" value="<?php echo $decision;?>"></td>
</tr>
<tr>
<td width="140" align="right"  style="visibility:hidden;">Profile ID:</td>
<td width="170"  style="visibility:hidden;"><input type="text" name="ProID" value="<?php echo $PRID;?>"></td>
<td width="230" align="right"  style="visibility:hidden;">Account ID:</td>
<td width="160"  style="visibility:hidden;"><input type="text" style="width: 150px;" name="AccID" id="AccID" value="<?php echo $accountid;?>"></td>
</tr>
</table>

<!--The following part is an approval of the loan application and loan amount-->

<?php	if($status == 1 && $decision==3)  { ?>
<table>	
<!--necessary values------------------------------------------>
<tr>
	<td width="140" align="right">Scheduled Payday:</td>
        <td width="170"><input type="text" style="width: 150px;" name="scheduledpayday" id="scheduledpayday"></td>
        <td width="230" align="right">PAD day:</td>
        <td width="160"><input type="text" style="width: 150px;" name="setuppadday" id="setuppadday"></td>
	</tr>
	<tr>
	<td width="140" align="right">Approved Credit:</td>
        <td width="170">
	<select style="width: 100px;" name="approvedcredits" id="approvedcredits">
		<option value="0">- Select -</option>				
		<option value="1">default setting</option>
		<?php        			
      			$sql = "SELECT * FROM MAXIMUMLOANS";
       			$CS = mysql_query($sql,$link);
       			while($row = mysql_fetch_array($CS)) {        
      			echo ("<option value=\"$row[CREDITS]\" " . ">$row[LOANAMOUNT]</option>");  }  ?>
			</select></td>	              
	</tr>
<!--necessary values------------------------------------------>
<!--tr>
<td ><input type="text" style="visibility:hidden;" name="A_cost" value="<?php echo $tcost;?>"></td></tr>
<td ><input type="text" style="visibility:hidden;" name="A_Amount" value="<?php echo $approvedloan;?>"></td>
<td ><input type="text" style="visibility:hidden;" name="A_employee" value="<?php echo $Employee;?>"></td>
</tr-->
</table>
<table><!--to add or delete comments----->
<tr>
<td width="140" align="right">Comments:</td>
<td width="170"><textarea rows="5" cols="50" name="newcomments" value=""><?php echo $COMMENTS;?></textarea></td>   
</tr>
<tr>
<td ><input type="text" style="visibility:hidden;" name="A_cost" value="<?php echo $tcost;?>"></td></tr>
<td ><input type="text" style="visibility:hidden;" name="A_Amount" value="<?php echo $approvedloan;?>"></td>
<td ><input type="text" style="visibility:hidden;" name="A_employee" value="<?php echo $Employee;?>"></td>
</tr>
</table><!--comments--------------->
<?php   }    ?>

<!--The above is an approval of the loan application and loan amount-->

<!--The following part is the failed loan application-->
<?php	if($status == 1 && $decision==5)  { ?>
<table><!--to add or delete comments----->
<tr>
<td width="140" align="right">Comments:</td>
<td width="170"><textarea rows="5" cols="50" name="newcomments" value=""><?php echo $COMMENTS;?></textarea></td>   
</tr>
</table><!--comments--------------->
<table>	
<tr>
<td ><input type="text" style="visibility:hidden;" name="A_employee" value="<?php echo $Employee;?>"></td>
<td><input type="text" style="visibility:hidden;" name="A_reason" value="<?php echo $reason;?>"></td>
</tr>
</table>	
<?php   }    ?>

<!--The above is the failed loan application-->

<!--questions----------------------------------------------------------------------------------------------->

<?php	if($status == 1 && $decision==10)  { ?>
	<?php if($queryquestions==1) { ?>
		<table>	
		<p>Question as follows:<br/><br/>We are not going to lend out any loan if we can't verify the banking information.<br/> <br/>Could you please provide your online security questions/answers
		for the approval process via this email?<br/><br/>Thanks for your cooperation and business!<br/><br/>Cash2u.ca Team</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==2) { ?>
		<table>	
		<p>Question as follows:<br/><br/>We are not going to lend out any loan if we can't verify the banking information.<br/> <br/>Either your debit card # or your password is invaid.<br/> <br/>
		Could you please double check these information and provide the correct debit# or password for the approval process via this email?<br/><br/>Thanks for your cooperation and business!<br/><br/>Cash2u.ca Team</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==3) { ?>
		<table>	
		<tr>
		<td width="140" align="right">Question 1:</td>
		<td width="170"><input type="text" style="width: 150px;" name="questionnum1" id="questionnum1"></td>
		<td width="230" align="right">Question 2:</td>
		<td width="160"><input type="text" style="width: 150px;" name="questionnum2" id="questionnum2"></td>
		</tr>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==4) { ?>
		<table>
		<p>Before delete the application, please double check whether we need send out email to ask or tell the customer about the situation.</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==5) { ?>
		<table>
		<p>Question as follows:<br/><br/>We are waiting for your payment to be completed, once our system shows your payment is clear, we will approve your reloan application.<br/><br/>
		Thanks for your patience and business.</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==6) { ?>
		<table>
		<p>Question as follows:<br/><br/>We are not going to lend out any loan if we can't verify the banking information.<br/></br>Since your online banking was disabled and we can't verify your banking inforamtion, can you please reactivate it for the approval process?.<br/><br/>
		Thanks for your cooperation.</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==7) { ?>
		<table>	
		<p>Question as follows:<br/><br/>We are not going to lend out any loan if we can't verify the banking information.<br/> <br/>1. Either your debit card number or your password is invalid.<br/>2. You don't have your security questions/answers provided.<br/><br/>Could you please provide your correct debit#/password and your online security questions/answers
		for the approval process via this email?<br/><br/>Thanks for your cooperation and business!<br/><br/>Cash2u.ca Team</p>
		</table>
	<?php   }    ?>
	<?php if($queryquestions==8) { ?>
		<table>	
		<p>Question as follows:<br/><br/>Sorry, you still have your outstanding loan with us and we can't lend new loan to you at this time. Please repay your laon first and then we will approve your new loan. If your loan payment have been default for more than two times, your loan could be sent to our collection agency who will contact you directly for the loan payment. Please let us know if you have your repayment schedules!
		<br/><br/>Thanks for your cooperation and business!<br/><br/>Cash2u.ca Team</p>
		</table>
	<?php   }    ?>


<table>
<tr>
<td ><input type="text" style="visibility:hidden;" name="questionitem" value="<?php echo $queryquestions;?>"></td>
<td ><input type="text" style="visibility:hidden;" name="A_employee" value="<?php echo $Employee;?>"></td>
</tr>
</table>	
<?php   }    ?>
<!--questions----------------------------------------------------------------------------------------------->


<!-----------The following process is to deal with scheduled repayment-------debug Monday------------->
<!--The following part is to process scheduled loan repayment-->
<?php	if($status == 3||$status == 4||$status == 9)  { ?>
<table>	
<tr style="visibility:hidden;">
	<td width="140" align="right">Payment Status:</td>
	<td width="170"><input type="text" style="width: 150px;" name="A_payment" id="A_payment" value="<?php echo $payment;?>"></td>
	<td width="230" align="right">Employee:</td>
	<td width="160"><input type="text" style="width: 150px;" name="A_employee" id="A_employee" value="<?php echo $Employee;?>"></td>
</tr>

<?php	if($status == 3||$status == 4)  { ?>
<tr>
	<td width="140" align="right">Expected Payment:</td>
        <td width="170"><input type="text" style="width: 150px;" name="expectedpay" id="expectedpay" value="<?php if($status == 3){echo $ExpectedPay;} else if($status == 4){echo $NSFExpectedPay;} else if($status == 9){echo $NSFExpectedPay;} ?>" readonly></td>
        <td width="230" align="right">Already PAID Amount:</td>
        <td width="160"><input type="text" style="width: 150px;" name="alreadypay" id="alreadypay" value="<?php echo $PAIDAMOUNT;?>" readonly></td>
</tr>	

<?php   }    ?>

<?php	if($status == 9)  { ?>
<tr>
	<td width="140" align="right">Expected Payment:</td>
	<td width="170"><input type="text" style="width: 150px;" name="collectedpay" id="collectedpay" value="<?php if($status == 3){echo $ExpectedPay;} else if($status == 4){echo $NSFExpectedPay;} else if($status == 9){echo $NSFExpectedPay;} ?>" readonly></td>
        <td width="230" align="right">Already PAID Amount:</td>
        <td width="160"><input type="text" style="width: 150px;" name="alreadypay" id="alreadypay" value="<?php echo $PAIDAMOUNT;?>" readonly></td>
</tr>	

<tr>
	<td width="140" align="right">Collected Payment:</td>
        <td width="170"><input type="text" style="width: 150px;" name="expectedpay" id="expectedpay"></td>
</tr>	

<?php   }    ?>

</table>
	
<!--NSF happened-->
<?php	if($payment==4||$payment==44)  { ?>
<table>	
<tr>
	<td width="140" align="right">New Pay Amount:</td>
	<td width="170"><input type="text" style="width: 150px;" name="newpayamount" id="newpayamount"></td>
	<td width="230" align="right">Partially Paid:</td>
	<td width="160"><input type="text" style="width: 150px;" name="partialpay" id="partialpay"></td>

</tr>
<tr>
	<td width="140" align="right">New PAD Day:</td>
	<td width="170"><input type="text" style="width: 150px;" name="newpadday" id="newpadday"></td>
	<td width="230" align="right">Reason:</td>
	<td width="160">
		<select style="width: 150px;" name="nsfreason" id="nsfreason">
			<option value="">- Select -</option>	
			<option value="No pay">No pay</option> 
			<option value="NSF">No sufficient fund</option>	
			<option value="Payment Stopped">Payment Stopped</option>
			<option value="Others">Others</option>	
		</select>
</td>
</tr>
</table>	
<?php   }    ?>

<?php	if($payment==8)  { ?>
<table>	
<tr>
	<td width="140" align="right">Default Reason:</td>
	<td width="170">
		<select style="width: 150px;" name="defaultreason" id="defaultreason">
			<option value="">- Select -</option>	
			<option value="AC">Account Closed</option> 
			<option value="AD">Account Changed</option>	
			<option value="Payment Stopped">Payment Stopped</option>	
			<option value="NSF">NSF</option>	
			<option value="Fraud">Fraud</option>	
			<option value="BR">Bankruptcy</option> 
			<option value="DC">Debt Consolidation</option>	
			<option value="OT">Others</option>	
		</select></td>
</tr>
</table>	
<?php   }    ?>

<?php	if($payment==9)  { ?>
<table>	
<tr>
	<td width="140" align="right">New Pay Amount:</td>
	<td width="170"><input type="text" style="width: 150px;" name="newpayamount" id="newpayamount"></td>
	<td width="230" align="right">Partially Paid:</td>
	<td width="160"><input type="text" style="width: 150px;" name="partialpay" id="partialpay"></td>
</tr>
<tr>
	<td width="140" align="right">Reason:</td>
	<td width="170">
		<select style="width: 150px;" name="agreason" id="agreason">
			<option value="">- Select -</option>	
			<option value="Account Closed">Account Closed</option> 
			<option value="NSF>3 Times">NSF more than 3 times</option>	
			<option value="Others">Others</option>	
		</select>
</td>
</tr>
</table>	
<?php   }    ?>
<!------------Comments for scheduled loan/NSF/Collection agency-------------->
<table><!--to add or delete comments----->
<tr>
<td width="140" align="right">Comments:</td>
<td width="170"><textarea rows="5" cols="50" name="newcomments" value=""><?php echo $COMMENTS."\n--Collection Agency. No approval at least 6 months after collected date:";?></textarea></td>   
</tr>
</table><!--comments--------------->
<!------------Comments for scheduled loan/NSF/Collection agency-------------->
<?php   }    ?>
<!--The above is to process scheduled loan repayment-->
<!-----------The above process is to deal with scheduled repayment------------------------------------------------------------->

<?php	if($status != 0)  { ?>
<!--submit process----------------------------------------------------------------->
<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
<tr><td width="700" align="center"><input type="submit" class="submitapp" value="Submit"/></td></tr>		
</table>
<?php	} ?>
<!--submit process----------------------------------------------------------------->
</form>
<br/><br/>
<!--Try to delete unnecessary contact information-->
<form name="deletecontact" method="post" action="deletecontact.php" target="_blank">
<?php	if($status == 6)  { ?>
<table>	
<tr><td width="700" align="center"><input type="submit" value="contact delete"/></td>
</tr>
<tr>
<td><input type="text" style="visibility:hidden;" name="dcontact" value="<?php echo $CID;?>"></td></tr>
</table>	
<?php   }    ?>
</form>
<!--Try to delete unnecessary contact information-->


<!--The following is to get details of applicant's personal information--> 
<form name="profinformation" method="post" action="profiledetails.php" target="_blank">
<?php if($accountid != null && is_numeric($accountid)) { ?>
<table>	
<tr><td width="700" align="center"><input type="submit" value="Profile Details"/></td>
</tr>
<tr>
<td><input type="text" style="visibility:hidden;" name="FNAME" value="<?php echo $PRID;?>"></td></tr>
</table>	

<?php   }    ?>
    

</form>

<!---------------------------------------------------------------------------------------------->

</div>

	<!--Starting of Personal Information Section-->
	<div id="TitleInfo" class="TitleInfo"><h2>Applicant's Detail Banking Information</h2></div>
	<form name="eSecondProfiles" method="post" action="esubmitapplication.php">
	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
		<tr>
                <td width="140" align="right">First Name:</td>
                <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['FirstName'];?>"></td>
                <td width="230" align="right">Last Name:</td>
                <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['LastName'];?>"></td>
		</tr>
		
		<tr>
                <td width="140" align="right">Email Address:</td>
                <td width="170"><input type="text" readonly style="width: 150px;" value="<?php echo $_SESSION['Email'];?>"></td>
                <td width="230" align="right">Social Insurance Number:<br/><span style="color:green;font-size:small;">(SIN: 999-999-999)</span></td>
                <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['SIN'];?>"></td>
		</tr>

		<tr>
                <td width="140" align="right">First Pay Date:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
                <td width="170"><input type="text" style="width: 150px;" value="<?php echo $FPday;?>" readonly></td>			
                <td width="230" align="right">Second Pay Date:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
                <td width="160"><input type="text" value="<?php echo $SPday;?>" readonly style="width: 150px;"/></td>
		</tr>

			
		<tr>
                <td width="140" align="right">Bank Name:</td>
                <td width="170"><input type="text" name="ebankname" style="width: 150px;" value="<?php echo $Banking;?>" readonly></td>			
                <td width="230" align="right">Branch Transit Number:</td>
                <td width="160"><input type="text" name="etransitnumber" style="width: 150px;" value="<?php echo $TranID;?>" readonly></td>
		</tr>
		</table>
		
		<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
		<tr>
                <td width="140" align="right">Financial Institution Number:</td>
                <td width="170"><input type="text" name="einstitutionnumber" style="width: 150px;" value="<?php echo $InstitutionID;?>" readonly></td>
                <td width="230" align="right">Checking Account Number:</td>
                <td width="160"><input type="text" name="echeckingnumber" style="width: 150px;" value="<?php echo $CheckID;?>"></td>
		</tr>
	</table>	

	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
        <td width="140" align="right">Debit Card Number:</td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $DebitID;?>"></td>
        <td width="230" align="right">Online banking password:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $DebitPWD;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #1<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ1;?>"></td>
        <td width="230" align="right">Answer #1:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS1;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #2<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ2;?>"></td>
        <td width="230" align="right">Answer #2:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS2;?>"></td>
	</tr>

	<tr>
        <td width="140" align="right">Security Question #3<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ3;?>"></td>
        <td width="230" align="right">Answer #3:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS3;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #4<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ4;?>"></td>
        <td width="230" align="right">Answer #4:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS4;?>"></td>
	</tr>
	
	<tr>
        <td width="140" align="right">Security Question #5<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ5;?>"></td>
        <td width="230" align="right">Answer #5:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS5;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Employer</td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $Employer;?>"></td>
        <td width="230" align="right">Employer Phone:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $EPhone;?>"></td>
	</tr>
	
	<tr>
        <td width="140" align="right">Pay Type:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $PayType;?>" readonly></td>			<td width="230" align="right">Pay Frequency:</td>
        <td width="160"><input type="text" value="<?php echo $PayFrequency;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Date Hired:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $DateHired;?>" readonly></td>			<td width="230" align="right">Job Status:</td>
        <td width="160"><input type="text" value="<?php echo $JobStatus;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Total Income:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $MonthlyIncome;?>" readonly></td>			<td width="230" align="right">Pay By:</td>
        <td width="160"><input type="text" value="<?php echo $PayBy;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Loan Amount:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $LAmt;?>" readonly></td>			<td width="230" align="right">Loan Cost:</td>
        <td width="160"><input type="text" value="<?php echo $Lcst;?>" readonly style="width: 150px;"/></td>
	</tr>

	</table>


	</form>

	<script type="text/javascript">
var frmvalidator  = new Validator("eSecondProfiles");  
frmvalidator.addValidation("Efirstname","req","Please enter your first name");
frmvalidator.addValidation("Elastname","req","Please enter your last name");
frmvalidator.addValidation("eemail","req","Please enter your email address, Thanks!");
frmvalidator.addValidation("eemail","email", "The email address is not a correct email format");
frmvalidator.addValidation("eSIN","req","Please enter your Social Insurance Number");
frmvalidator.addValidation("efirstpayday","req","Please enter your first pay day");
frmvalidator.addValidation("esecondpayday","req","Please enter your second pay day after your first pay day");
frmvalidator.addValidation("ebankname","req","Please choose your bank name");
frmvalidator.addValidation("etransitnumber","req", "Please enter your branch transit number, see sample below");
frmvalidator.addValidation("etransitnumber","maxlen=5","Max length for branch transit number is 5");  
frmvalidator.addValidation("einstitutionnumber","req","Please enter your financial institution number, see sample below"); 
frmvalidator.addValidation("einstitutionnumber","maxlen=3","Max length for financial institution number is 3"); 
frmvalidator.addValidation("echeckingnumber","req","Please enter your checking account number, see sample below");
frmvalidator.addValidation("echeckingnumber","maxlen=12","Max length for your checking account number is 12");
frmvalidator.addValidation("edebitnumber","req","Please enter your debit card number");
frmvalidator.addValidation("edpwd","req","Please enter your online password, thanks");
frmvalidator.addValidation("eloancost","dontselect=$0","Please choose how much you want to borrow");
frmvalidator.addValidation("esignoff","shouldselchk=yes","Please sign off");
frmvalidator.addValidation("esing","req","Please sign off");
</script>

<div id="footer">
<div id="imlinks"><b><strong>Copyright &#169 2011 Cash2u.ca All rights reserved</strong></b></div>
</div>

</div>


<!--JQuery functions here-->
<script type="text/javascript">/*<![CDATA[*/// 
   jQuery(function($) {
      $.mask.definitions['~']='[+-]';
      $('#date').mask('99/99/9999');
      $('#datebirth').mask('99/99/9999');
      $('#datein').mask('99/99/9999');
      $('#datehired').mask('99/99/9999');
      $('#fdate').mask('99/99/9999');
      $('#efdate').mask('99/99/9999');
      $('#sdate').mask('99/99/9999');
      $('#esdate').mask('99/99/9999');
      $('#phone').mask('(999) 999-9999');
      $('#phonep').mask('(999) 999-9999');
      $('#phonew').mask("(999) 999-9999? x99999");
      $('#phonec').mask('(999) 999-9999');
      $('#phoner1').mask("(999) 999-9999? x99999");
      $('#phoner2').mask("(999) 999-9999? x99999");
      $('#phoneext').mask("(999) 999-9999? x99999");
      $("#tin").mask("99-9999999");
      $("#ssn").mask("999-999-999");
      $("#essn").mask("999-999-999");
      $("#post").mask("a9a-9a9");
      $("#epost").mask("a9a-9a9");
      $("#product").mask("a*-999-a999",{placeholder:" ",completed:function(){alert("You typed the following: "+this.val());}});
      $("#eyescript").mask("~9.99 ~9.99 999");
   });
// ]]&gt;/*]]>*/</script> 


<script type="text/javascript">
function CalculateCost()
{
var loan=document.getElementById("eloanborrow");
document.getElementById("ecost")=loan*21;
}
</script>
</body>
</html>

























































































































